home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: The Amorphous Mass <robinson@blue.weeg.uiowa.edu>
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: Re: const pointer confusion...
- Date: 24 Mar 1996 11:42:20 -0600
- Organization: University of Iowa, Iowa City, IA, USA
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4j41hs$nku@solutions.solon.com>
- References: <4j06gm$7oa@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
- X-Sender: robinson@green.weeg.uiowa.edu
-
- On 23 Mar 1996, Reed R. Mangino wrote:
-
- > Could someone please straighten me out on this:
- >
- > 1) const int *p = 10;
- > p is a constant pointer to an int, right? While p can be made to
- > point to something else, *p can never be assigned to, right?
-
- No, p is a pointer to a constant integer. However, you are right that
- *p cannot change, but p can.
-
- > 2) int *const p;
- > p is a pointer to an integer. *p can be assigned to, but p can
- > never be made to point to another address in memory, right?
-
- This is a syntax error.
-
- > 3) int const *p;
- > What the heck is this? I can't find anything like this in my
- > books, but my compiler thinks everything is hunky doory!???
-
- This is a constant pointer to an integer. *p can be changed, but p
- cannot.
-
- Also, there's
-
- 4) const int const *p;
-
- Which is a constant pointer to a constant integer; neither *p nor
- p can change.
-
- /**James Robinson***********************
- "If a fatal error occurs, the program should not be allowed to continue."
- -- Oracle Pro*C User's Guide *************james-robinson@uiowa.edu**/
-